package uit.shoeshop.model;

import uit.shoeshop.dto.CategoryDTO;
import uit.shoeshop.dto.ProductDTO;
import uit.shoeshop.dao.CategoryDAO;
import uit.shoeshop.dao.ProductDAO;

import java.sql.SQLException;
import java.util.ArrayList;

public class SearchModel {
	public SearchModel(){
		
	}
	
	public ArrayList<ProductDTO> getAllProductbyKeyword(String keyword,int page) throws SQLException{
		ArrayList<ProductDTO> product = new ArrayList<ProductDTO>();

		ProductDAO tblProduct = new ProductDAO();
		/*
		 * Lay tat ca cac product cua keyword
		 */
		product = tblProduct.getProductbyKeyword(keyword, page);
		
		tblProduct = null;
		return product;
	}
		
	public Integer countTotalProduct(String keyword) throws SQLException{
		Integer result = 0;

		ProductDAO tblProduct = new ProductDAO();
		/*
		 * Dem tong san pham trong keyword
		 */
		result = tblProduct.countProductbyKeyword(keyword);
		
		tblProduct = null;
		return result;
	}
}
